
const Router = require('express').Router()
const userMiddleWare = require('../middleware/userMiddleware')
const userController = require('../controllers/userController')
const { uploader, verifyUpload } = require('../utils/uploadAvatar')

// 路由守卫
Router.use((req, res, next) => {
    next()
})

// 登录
Router.post('/login', userMiddleWare.login, userController.login)

// 注册
Router.post('/register', userMiddleWare.register, userController.register)

// 修改资料
Router.post('/updateInfo', userMiddleWare.updateInfo, userController.updateInfo)

// 获取资料
Router.post('/getUserInfo', userMiddleWare.getUserInfo, userController.getUserInfo)

// 上传头像
Router.post('/uploadAvatar', userMiddleWare.uploadAvatar, uploader.single('avatar'), verifyUpload, userController.uploadAvatar)

// 更改密码
Router.post('/resetPassword', userMiddleWare.resetPassword, userController.resetPassword)



module.exports = Router